#ifndef SOLUTIONS_H
#define SOLUTIONS_H

#include <QDir>
#include <QObject>

#define SO_DIR_OK         0x00
#define SO_DIR_Fail       0x01
#define SO_DIR_EMPTY      0x02
#define SO_DIR_NO_EXISTS  0x03
#define SO_DIR_NO_DOT_GIT 0x04

static const char * const 
SO_DIR_STATES[] = {
    [SO_DIR_OK        ] = "已检出",
    [SO_DIR_Fail      ] = "未检出",
    [SO_DIR_EMPTY     ] = "空项目",
    [SO_DIR_NO_EXISTS ] = "不存在",
    [SO_DIR_NO_DOT_GIT] = "非仓库",
};

class Solution {
public:
    virtual QString name() = 0;
    virtual QString state() = 0;
    virtual bool solution(const QString &workdir, const QString &name, const QString &path) = 0;
    virtual bool solution_apply(const QString &workdir, const QString &name, const QString &path) = 0;
    virtual bool solution_undo(const QString &workdir, const QString &name, const QString &path) = 0;

protected:
    QString path_in_work(const QString &workdir, const QString &path, const QString &userdata = "") {
        auto v = workdir + QDir::separator() + path;
        if (userdata.isEmpty() == false) {
            v = v + QDir::separator() + userdata;
        }
        return v;
    }
};

typedef std::vector<Solution> Solutions;

#endif // SOLUTIONS_H
